home *** CD-ROM | disk | FTP | other *** search
/ Hack-Mag 3 / Hack-Mag - Issue 3 (1991-02-02)(D-Tect)(PD).adf / Sources / CoderCorner.bas next >
BASIC Source File  |  2014-06-19  |  2KB  |  42 lines

  1.   Iter = 3
  2.   amin = -3
  3.   amax = 1
  4.   bmin = -1
  5.   bmax = 1.5 
  6.   x=1:y=1                      'startcoordinates on the Screen(for GFX)
  7.   xend=xs+100:yend=ys+100
  8.   cr=amin:ci=bmax              'real/imaginary startvalues of c
  9.   zr=0:zi=0                    '  "     "      values of z(0)
  10.   AStep=(amax-amin)/100:BStep=(bmax-bmin)/100
  11.  
  12.   WHILE y<yend                 'until it is 100 pixels high
  13.     FOR s=1 TO Iter            'Iter is the max allowed numbers of iterations
  14.                                'when there are no attractors found before
  15.                                'the loop will be leaved
  16.       sr=zr*zr-zi*zi+cr        'New real part=old real part^2-old imaginary
  17.                                'part + realpart of actual c
  18.       si=2*zi*zr+ci            'new im. part = 2*[old im. part]*[old real part]
  19.                                '+im. part of actual c
  20.       r=sr*sr+si*si            'if squareroot of r<2 then this point is not
  21.                                'part of the Mandelbrot-picture
  22.       IF r>=4 THEN GOTO LoopExit
  23.       zr=sr                    'Old real part = new real part
  24.       zi=si                    'Old im. part = new im. part
  25.     NEXT s                     'the loop again
  26.  LoopExit:
  27.     zr=0:zi=0                  'clear them again (for next point)
  28.     IF r>=4 THEN PSET(x-1,y),s-1   'if point belongs to the "Apfelmännchen"
  29.                                'it is set in a color depending on the
  30.                                'number of iterations 
  31.     x=x+1                      'xScreencoordinate of next point
  32.     IF x>xend THEN             'if already 100 pixels made we must start the
  33.                                '2nd
  34.       y=y+1                    'next line
  35.       x=1                      'x is on the left again
  36.       cr=amin                  'real part is left again, too
  37.       ci=ci-BStep              'im. part is now one line deeper
  38.     ELSE                       'if not 100 pixels in x made then
  39.       cr=cr+AStep              'real part one point right
  40.     END IF
  41.   WEND
  42.